<template>
	<view :style="{paddingTop:`${h}px`}">
		
		<!-- #ifdef MP-WEIXIN -->
		<view>
			只在微信小程序平台显示
		</view>
		<!-- #endif -->
		<!-- #ifdef H5 -->
		<view>
			只在h5平台显示
		</view>
		<!-- #endif -->
		
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item v-for="(item,index) in list" :key="index">
				<image :src="item.pic" mode="scaleToFill" style="width: 100%;"></image>
			</swiper-item>
		</swiper>
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" :display-multiple-items="2">
			<swiper-item>
				<view class="swiper-item item-test">123</view>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item item-test">456</view>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item item-test">789</view>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item item-test">123</view>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item item-test">456</view>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item item-test">789</view>
			</swiper-item>
		</swiper>
		<view class="box-wrapper">
			<view class="box">
				12
			</view>
			<view class="box">
				34
			</view>
			<view class="box">
				56
			</view>
			<view class="box">
				78
			</view>
			<view class="box">
				90
			</view>
		</view>
	</view>
</template>

<script>
	import HomeApi from "@/api/home/index.js"

	export default {
		data() {
			return {
				list: [],
				h: 0
			}
		},
		onLoad(option) {
			let _this = this
			// 获取 刘海屏/状态栏 高度
			uni.getSystemInfo({
				success(res) {
					console.log("刘海屏/状态栏 高度：", res.statusBarHeight)
					_this.h = res.statusBarHeight
				}
			})

			// 本代码段仅在微信小程序平台编译
			// #ifdef MP-WEIXIN
			// 获取微信小程序右上角胶囊按钮位置信息
			console.log(uni.getMenuButtonBoundingClientRect())
			// #endif

			HomeApi.bannerAds().then(res => {
				this.list = res.data.items
			}).catch((err) => {
				console.log(err)
			})

			HomeApi.doLogin({
				"password": "123456",
				"username": "17596496508"
			})

			HomeApi.findCategory("1308336521604599809")

			HomeApi.findProductList(1, 10, {
				"brandId": "",
				"categoryId": "1308339256886423554",
				"isDesc": 0,
				"keywords": "",
				"sortBy": "price"
			})
		},
		methods: {

		}
	}
</script>

<style lang="scss" scoped>
	.box-wrapper {
		display: flex;
		align-items: center;
		overflow-x: auto;
	}

	// 设计稿1px/设计稿总宽度 = 1rpx/750rpx
	.box {
		width: 180rpx;
		height: 140rpx;
		background-color: red;
		// 总宽度超过父元素时不要自动缩放
		flex-shrink: 0;
		margin: 0 20rpx;
	}

	.item-test {
		background-color: blue;
		margin: 0 20rpx;
	}
</style>
